﻿using System;

namespace Data.implement
{
    class PriceRecordRepositery : DataAccessBase<LYWebsiteSEntities1>, IPriceRecordRepositery
    {
        public bool InsertPriceRecord(string address, string phoneNum, string name, WeiXinUser userInfo)
        {
            var check = GetRecordByProperty<PriceRecord>(d => d.OpenId == userInfo.openId);
            if (check == null || check.OpenId == null)
            {
                PriceRecord result = new PriceRecord()
                {
                    address = address,
                    OpenId = userInfo.openId,
                    UpdateTime = DateTime.Now,
                    city = userInfo.city,
                    country = userInfo.country,
                    headimgurl = userInfo.headimgurl,
                    name = name,
                    nickname = userInfo.nickname,
                    phoneNum = phoneNum,
                    province = userInfo.province,
                    sex = userInfo.sex
                };
                InsertRecord(result);
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}